package com.xiaoke.interview;

import java.io.File;

/**
 * @Author XiaoKe
 * @Date 2020-10-08 17:09
 * @Description 使用递归算法输出某个目录下及其子目录下所有文件
 */
public class ShowFile {

    private static void test(String path) {
        File file = new File(path);
        File[] files = file.listFiles();

        if (files == null) {
            return;
        }

        for (File file1 : files) {
            if (file1.isFile()) {
                System.out.println(file1.getPath());
            } else {
                test(file1.getPath());
            }
        }
    }

    public static void main(String[] args) {
        String path = "E:\\图片";
        test(path);
    }
}
